import requests
from bs4 import BeautifulSoup
import datetime

# 发送 HTTP 请求获取网页内容
url = 'http://202.127.45.18/Index'  # 替换为实际的网页 URL
response = requests.get(url)
html_content = response.text

# 使用 BeautifulSoup 解析 HTML 文档
soup = BeautifulSoup(html_content, 'html.parser')

# 查找所有 script 标签
script_tags = soup.find_all('script')
timedata = datetime.datetime.now().strftime('%Y%m%d')

# 提取每个 script 标签中的内容
for script in script_tags:
    script_content = script.string
    if script_content:
        # 保存到文件
        with open(f'{timedata}_种子实时价格.txt', 'a', encoding='utf-8') as f:
            f.write(script_content)